import System.IO
import Control.Monad
import Data.List
import Data.List.Split
import Data.Char
import Data.Ord

triangleNumbers = take 27 $ scanl (+) 1 [2..]

isTriangular :: Int -> Bool
isTriangular n = let x = floor (sqrt (fromIntegral (2*n))) in (x*(x+1) `div` 2) == n

alphaScore :: String -> Int 
alphaScore xs = sum $ map ((subtract 64).ord) xs

main = do
	list <- readFile "words.txt"
	let euler_042 = length $ filter id $ map (isTriangular.alphaScore) $ splitOn "," $ filter (/='\"') list
	(putStrLn.show) euler_042
	
